package com.kevin.ymqquan.adapter;

import java.util.List;

import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.kevin.ymqquan.R;
import com.kevin.ymqquan.bean.CourseDList;

public class CourseDListAdapter extends BaseAdapter {

	private List<CourseDList> activeList;
	private LayoutInflater lf;

	public CourseDListAdapter(Activity mContext,
			List<CourseDList> activeList) {
		super();
		this.activeList = activeList;
		this.lf = (LayoutInflater) mContext
				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return activeList.size();
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		ActivebHolder holder = new ActivebHolder();
		if (convertView == null) {
			convertView = lf.inflate(R.layout.list_active_item, parent, false);
			holder.tv_active_item_activeName = (TextView) convertView
					.findViewById(R.id.tv_active_item_activename);
			holder.tv_active_item_activeTime = (TextView) convertView
					.findViewById(R.id.tv_active_item_activetime);
			holder.tv_active_item_venueName = (TextView) convertView
					.findViewById(R.id.tv_active_item_venuename);
			convertView.setTag(holder);
		} else {
			holder = (ActivebHolder) convertView.getTag();
		}

		holder.tv_active_item_activeName.setText(activeList.get(position)
				.getActiveName());
		holder.tv_active_item_activeTime.setText(activeList.get(position)
				.getActiveTime());
		holder.tv_active_item_venueName.setText(activeList.get(position)
				.getVenueName());

		return convertView;
	}

	/**
	 * 自定义控件集合
	 */
	public static class ActivebHolder {
		// 名称
		public TextView tv_active_item_activeName;
		// 所有人
		public TextView tv_active_item_activeTime;
		// 地址
		public TextView tv_active_item_venueName;
	}

}
